package com.wenchao.bluetoothdemo;

import android.os.Bundle;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

import com.wenchao.libbluetooth.BluetoothManager;

/**
 * @author zhangwenchao
 */
public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }


    public void open(View view) {
        if (BluetoothManager.getInstance().isBluetoothSupported() && !BluetoothManager.getInstance().isBluetoothEnabled()) {
            BluetoothManager.getInstance().turnOnBluetooth();
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (BluetoothManager.getInstance().isBluetoothSupported() && BluetoothManager.getInstance().isBluetoothEnabled()) {
            BluetoothManager.getInstance().turnOffBluetooth();
        }
    }

}